<template>
	<view class="">
		<view class="head_top" style="position: sticky;;z-index: 1;">
			<u-tabs :list="tabs" :current="current" @change="current=$event" :activeColor="$zs" />
		</view>
		<view class="bg-fff p20 flex row-between mt10" v-if="type=='join'&$user.invite_num" @click="$jump('/pages/my/team/invite_my')">
			<text>您有{{$user.invite_num}}条加入邀请通知，前去处理</text>
			<view class="">
				<u-icon name="arrow-right"></u-icon>
			</view>
		</view>
		<view class="p30">
			<u-empty v-if="!list.length" marginTop="100"></u-empty>
			<view class="p20 bg-fff radius20 mb20" @click="jump(item)" v-for="(item,index) in list" :key="index">
			<!-- 	<view class="mr20">
					<image :src="item.avatar" class="w160 h160" mode=""></image>
				</view>
				<view class="flex1 als-s flex-col row-between">
					<view class="line-1 fw-w fs30">{{item.name}}</view>
					<view class="fs24 color-999">创建时间：{{item.create_time}}</view>
					<view class="flex">
						<view class=" color-666">转单待处理</view>
						<view class="fs32 ml10">{{item.trade_order}}</view>
					</view>
				</view> -->
				<masterInfo :data="item" />
			</view>
		</view>
		<view class="h120"></view>
		<view class="pf w-max left0 bottom0 bg-fff">
			<view class="flex1 p20" v-if="type=='manage'">
				<u-button type="warning" ripple @click="$jump('/pages/my/team/creation')">创建团队</u-button>
			</view>
			<view class="flex1 p20" v-if="type=='join'">
				<u-button type="warning" ripple @click="$jump('/pages/my/team/joinList')">加入团队</u-button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				current: 0,
				tabs: [{ //	manage=管理的团队，join=加入的团队
						name: '管理的团队',
						id: 'manage',
					},
					{
						name: '加入的团队',
						id: 'join'
					}
				],
				list: [],
				page: 1,
			};
		},
		computed: {
			type() { //anage=管理的团队，join=加入的团队
				return this.tabs[this.current].id
			}
		},
		watch: {
			type() {
				this.getList()
			}
		},
		onShow() {
			this.getList()
			if(this.type=='join')this.$getUser()
		},
		onReachBottom() {
			this.getList('down')
		},
		methods: {
			jump(item) {
				if (this.$params.set) {
					uni.$emit(this.$params.set, item)
					this.$navBack()
				} else {
					this.$jump('details', {
						agency_id: item.id
					})
				}
			},
			getList(e) {
				e == 'down' ? this.page++ : this.page = 1
				let params = {
					page: this.page,
					type: this.type
				}
				this.$request('/master/agency/agencyList', params).then(res => {
					let list = res.data.data
					e == 'down' ? this.list.push(...list) : this.list = list
				})
			},
		}
	}
</script>

<style lang="scss">
	.head_top {
		top: 0px;
		/* #ifdef H5 */
		top: 44px;
		/* #endif */
	}
</style>